package com.czwx.bee.business.manager.modular.cloanuser.controller;


import com.czwx.bee.base.common.dto.ResponseDto;
import com.czwx.bee.base.common.exception.BizExceptionEnum;
import com.czwx.bee.base.web.common.BaseController;
import com.czwx.bee.business.manager.modular.cloanuser.dto.CloanAuthUserDto;
import com.czwx.bee.business.manager.modular.cloanuser.model.query.CloanUserAuthQuery;
import com.czwx.bee.business.manager.modular.cloanuser.service.CloanUserAuthService;
import com.czwx.bee.business.manager.modular.sys.model.SecurityUser;
import com.czwx.bee.business.manager.utils.SecurityUtil;
import io.swagger.annotations.*;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping(value = "/cloanuser_auth")
@Api(value = "CloanUserAuthController",tags = "借款用户认证控制器")
public class CloanUserAuthController extends BaseController {

    @Autowired
    private CloanUserAuthService cloanUserAuthService;


    @PostMapping("/list")
    @ApiOperation(value = "分期用户授权列表", notes = "可分页条件查询", httpMethod = "POST")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Authorization", value = "请输入凭证", required = true, dataType = "String", paramType = "header"),
            @ApiImplicitParam(name = "cloanUserAuthQuery", value = "请输入查询信息", required = true, dataType = "CloanUserAuthQuery", paramType = "body") })
    @ApiResponses(
            @ApiResponse(code = 200,response = CloanAuthUserDto.class,message = "data：中返回list")
    )
    public ResponseDto list(@RequestBody CloanUserAuthQuery cloanUserAuthQuery) throws Exception {
        ResponseDto rs=new ResponseDto(BizExceptionEnum.SUCCESSFUL_OPERATION);
        SecurityUser securityUser=SecurityUtil.getSecurityUser();
        Map params=objectToMap(cloanUserAuthQuery);
        params.put("drainageId",securityUser.getDrainageId());
        PageQuery query=  new PageQuery(cloanUserAuthQuery.getPage(),cloanUserAuthQuery.getSize(),objectToMap(cloanUserAuthQuery));
        cloanUserAuthService.getPageList(query);
        rs.setData(query);
       return rs;
    }
}
